package com.muse.app.controller;

import com.muse.app.service.UserService;
import com.muse.entity.Result;
import com.muse.entity.UserInfo;
import com.muse.interceptor.CurrentContext;
import com.muse.model.CreateCustomerArchivesParam;
import com.muse.model.UpdateUserParam;
import com.muse.model.UserInfoVo;
import com.muse.model.updatePhoneParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created with IntelliJ IDEA.
 * User: lee
 * Date: 2021/5/12
 * Time: 11:19 上午
 * Description:
 */
@RestController
@RequestMapping(value = "/muse/user")
@Slf4j
public class UserContraooler {

    @Autowired
    private UserService userService;

    @GetMapping("/me")
    public Result<UserInfoVo> me() {
        Integer id = CurrentContext.getUserId();
        return userService.me(id);
    }

    @PostMapping("/updateUserInfo")
    public Result updateUserInfo(@RequestBody UpdateUserParam param) {
        log.info("app user updateUserInfo,param={}", param);
        return userService.updateUserInfo(param, CurrentContext.getUserId());
    }

    @PostMapping("/updatePhone")
    public Result updatePhone(@RequestBody updatePhoneParam param) {
        log.info("app user updatePhone,param={}", param);
        return userService.updatePhoneParam(param, CurrentContext.getUserId());
    }
}
